var baseServicePath = "services/";
var baseImageContentServicePath = baseServicePath + "imageContent/";

var validEmailRegex = /^((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*?)\s*;?\s*)+/;

function log(text) {
    console.log(new Date() + ": " + text);
}

function TODO(text) {
    console.log(new Date() + ": TODO: " + text);
}

function addToBody(elem) {
    $('body').append(elem);
}

function get(url, callback) {
    $.getJSON(baseImageContentServicePath + url, callback);
}

function loadAllTagsAnd(callback) {
    get("tags", function(tags) { callback(tags) });
}

function loadImagesForTagAnd(tag, callback) {
    get("tag/" + tag, function(images) { callback(images) });
}

function loadLatestImagesAnd(callback) {
    get("latest", function(images) { callback(images) });
}

function calculateImageProperties(image) {
    image.grayscaleThumbnailSrc = baseImageContentServicePath + "thumb/grayscale/" + image.name;
    image.thumbnailSrc = baseImageContentServicePath + "thumb/" + image.name;
    image.imageFile.thumbnailSrc = image.thumbnailSrc;
    image.imageFile.src = baseImageContentServicePath + "image/" + image.name;
    var milliseconds = image.date;
    var date = new Date(milliseconds);
    image.dateText = date.format("mmm yyyy");
}

